<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://photos">

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="object[@type='photoalbum']" mode="album-bar">
		<xsl:param name="userId" />
		<xsl:param name="userGroup" />
		<xsl:param name="id" select="@id" />
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		
		<div id="photoalbum_info">
			<div id="owner_avatar">
				<a href="{$baseURI}/user/{$userLogin}">
					<img>
						<xsl:attribute name="src">
							<xsl:if test="property[@name='user_avatar']/value = ''">
								<xsl:value-of select="concat ($baseURI, '/images/default-avatar.png')" />
							</xsl:if>
							<xsl:if test="property[@name='user_avatar']/value != ''">
								<xsl:value-of select="concat ($baseURI, '/thumb_50_50', property[@name='user_avatar']/value)" />
							</xsl:if>
						</xsl:attribute>
						<xsl:attribute name="alt">
							<xsl:value-of select="property[@name='user_name']/value" />
						</xsl:attribute>
					</img>
				</a>
			</div>
			<div id="owner_info">
				<h3>
					<xsl:text>«</xsl:text>
					<a href="{$baseURI}/photoalbum/{$id}">
						<xsl:value-of select="property[@name='title']/value" />
					</a>
					<xsl:text>» ― &labelAlbumOfUser; </xsl:text>
					<a href="{$baseURI}/user/{$userLogin}">
						<xsl:value-of select="property[@name='user_name']/value" />
					</a>
					
					<xsl:if test="property[@owner_id]/value = $userId or $userGroup = 'admin' or $userGroup = 'moderator'">
						<span>
							<a href="{$baseURI}/photos/edit_album/{$id}">
								<img src="{$baseURI}/images/settings-icon.png" />
							</a>
							<xsl:text> </xsl:text>
							<a onclick="if(!confirm('&labelAlbumDeleteConfirm;'))return false;" href="{$baseURI}/photos/delete_album/{$id}">
								<img src="{$baseURI}/images/delete-icon.png" />
							</a>
						</span>
					</xsl:if>
				</h3>
				<div id="owner_menu">
					<a href="{$baseURI}/user/{$userLogin}">&labelUserProfile;</a>
					<a href="{$baseURI}/blogs/user/{$userLogin}">&labelUserBlog;</a>
					<a href="{$baseURI}/photos/user/{$userLogin}" class="selected">&labelUserPhotos;</a>
				</div>
				<div id="photoalbum_description">
					<xsl:value-of select="property[@name='description']/value" />
				</div>
			</div>
		</div>
	</xsl:template>
		
</xsl:stylesheet>	